package first.forHuaWei.贪心;

/**
 * @ClassName LC122
 * @description:
 * @author: 荣燊
 * @create: 2021-09-06 10:34
 **/
public class LC122 {
    // 买卖股票的最佳时机 II，所有的升序段
    public static void main(String[] args) {
        int[] prices = {7, 1, 5, 3, 6, 4};

    }

    public static int maxProfit(int[] prices) {
        int n = prices.length;
        int maxP = 0;
        for (int i=1; i<n; i++) {
            maxP += Math.max(0, prices[i]-prices[i-1]);
        }
        return maxP;
    }
}
